import java.util.Arrays;
import java.util.Scanner;

/**
 * DomWon
 * Created with Intellij IDEA.
 * Description:
 * User:WEI
 * Date:2023/3/10
 * Time:15:54
 */
public class TestDemo {
    public static void main(String[] args) {
        int[] array = {1,2,3,4,5,6,7,8,9,8,7,6,5,4,3,2,1};
        int ret = search(array);
        System.out.println(ret);
    }

    public static int search (int[] array) {
        int ret = 0;
        for (int i = 0; i < array.length; i++) {
            ret ^= array[i];
        }
        return ret;
    }

    public static void main4(String[] args) {
        Scanner scan = new Scanner(System.in);
        int[] array = new int[10];
        for (int i = 0; i < array.length; i++) {
            array[i] = scan.nextInt();
        }
        int target = scan.nextInt();
        first : for (int i = 0; i < array.length; i++) {
            for (int j = 0; j < array.length; j++) {
                if(array[i]+array[j]==target) {
                    System.out.println("["+i+","+j+"]");
                    break first;
                }
            }
        }
    }

    public static void main3(String[] args) {
        int[] array = {9,8,7,6,5,4,3,2,1};
        bubbleSort(array);
    }

    public static void bubbleSort(int[] array) {
        for (int i = 0; i < array.length; i++) {
            boolean flag = true;
            for (int j = 0; j < array.length-1-i; j++) {
                if(array[j]>array[j+1]) {
                    int tmp = array[j];
                    array[j] = array[j+1];
                    array[j+1] = tmp;
                    flag = false;
                }
            }
            if(flag == true) {
                System.out.println(Arrays.toString(array));
            }
        }
    }

    public static void main2(String[] args) {
        int[] array = {1,2,3,4,5,6,7,8,9,10};
        int pos = dichotomySearch(array,5);
        System.out.println(pos);
    }

    public static int dichotomySearch(int[] array,int num) {
        int left = 0;
        int right = array.length - 1;
        int mid = left + (left + right) / 2;
        while(left < right) {
            if(array[mid] == num) {
                return mid;
            }
            if(array[mid] > num) {
                    left = mid - 1;
                    mid = left + (left+right) / 2;
            }
            if(array[mid] < num) {
                    right = mid + 1;
                    mid = left + (left+right) / 2;
            }
        }
        return -1;
    }

    public static void main1(String[] args) {
        int[] array = {1,2,3,4,5,6};
        sort(array);
    }

    public static void sort(int[] array) {
        int j = 0;
        int k = array.length / 2;
        int[] array1 = new int[array.length];
        for (int i = 0; i < array.length; i++) {
            if (array[i] % 2 != 0) {
                array1[j] = array[i];
                j++;
            } else {
                array1[k] = array[i];
                k++;
            }
        }
        System.out.println(Arrays.toString(array1));
    }
}
